Filename | Programs use the name of a device file to open the device using open(). |
Permissions, Owner ID, Group ID | The file access permissions, owner ID, and group ID of a device file establish which users can read and which can write to that device. |
Block or Character | A device file belongs to one of two classes, block or character, visible as the first letter of an ls -l display. |
Major device number | A code for the device driver that controls this device. |
Minor device number | A code specifying the unit or position of this device under its controller. |
All this information is visible in a display produced by ls -l. The major and minor numbers are shown in the column used for file size for regular files. Examine the output of a command such as
A device special file can be used the same as a regular file in most IRIX commands; for example, a device file can be the target of a symbolic link, the destination of redirected input or output, and so on.ls -l /dev/* | more
A character device such as a printer accepts or returns data as a stream of bytes, and usually acts as a sink or source of data--the medium cannot be repositioned and read again. The driver for a character device typically transfers data as soon as it is requested and completes one operation before accepting another request. Character devices are also called raw devices, because their input is not buffered.
The possible major numbers are declared and given names in the file sys/major.h. When you create a new kernel-level device driver you must choose a major number for it--a number not used by any other driver. Numbers 60-79 are not used by Silicon Graphics. (See "Selecting a Major Number".)
In IRIX releases through 5.2 (and 6.0.x, which is based on 5.2), major numbers were limited to the range 0 through 254. Beginning with releases 5.3 and 6.1, the IRIX inode structure permits major numbers to have up to 14 bits of precision. However, major numbers are currently restricted to at most 9 bits to conserve kernel data space.
In order to use this limit symbolically, use the name L_MAXMAJ defined in sys/sysmacros.h. When you declare a variable for a major device number in a program, use type major_t declared in sys/types.h.
Normally a device driver services only one major number. However, it is possible to designate the same device driver to service more than one major number. In this case, the driver may need to discover the major number at execution time. The getemajor() function returns the number in use for a given request (see the getemajor(D3) reference page).
With STREAMS drivers, the minor device number can be chosen arbitrarily during a CLONE open--see "Support for CLONE Drivers".